$(document).ready(function() {

    $(function () {
        $("#register").click(function () {
                let userId = $("#register-userid").val();
                let userName = $("#register-username").val();
                let userPwd = $("#register-password").val();
                let userQuestion = $("#register-question").val();
                $.ajax({
                    url: '/user/register',
                    type: 'post',
                    dataType: 'json',
                    data:{"userId":userId,"userName":userName.toString(),"userPwd":userPwd.toString(),
                        "userQuestion":userQuestion.toString()},

                    success:function(data) {
                        console.log(data);
                        if(data=true){
                            swal({
                                    title: "注册成功!",
                                    text: "请点击继续！",
                                    type: "success",
                                    confirmButtonColor: "#2a67ec",
                                    confirmButtonText: "继续！"
                                },
                                function (isConfirm) {
                                    if (isConfirm) {
                                        window.location.href="../web/login.html";
                                    }
                                });
                        }
                    },
                    error:function (){
                        swal({title:"已存在该用户ID，请改用其他ID",type:"error"});
                    }
                });

            }
        )


    });
})
